﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GrayParrot.Web.Formly;

namespace FimetContoDeposito.BLL.Metadata
{
    /// <summary>
    /// Metadata per la maschera di movimento carico...
    /// </summary>
    public class AnagraficaDocumentiMetadataCarico
    {
        [FieldGroup(GroupName = "zero", Row = 1, Index = 1, NumberOfColumns = 12)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptions(Label = "Note distinta di carico", Placeholder = "Indicare le note della distinta, se necessarie...", Required = false)]
        public string NoteDistinta { get; set; }

        [FieldGroup(GroupName = "primo", Row = 1, Index = 1, NumberOfColumns = 4)]
        [FormFieldAttribute(Type = FormFieldTypes.GrayParrotDateTimePicker)]
        [GrayParrotDateTimePickerOptionsAttribute(Label = "Data Movimento",
                                 Placeholder = "Indicare la data del movimento...",
                                 Required = false,
                                 MinuteStep = 10,
                                 Language = "it",
                                 Format = "dd/mm/yyyy hh:ii",
                                 WithInitialDate = true,
                                 ShowMeridian = false)]
        public DateTime DataMovimento { get; set; }

        [Events(Event = EventTypes.OnChange, Callback = "CambiaMagazzino")]
        [FieldGroup(GroupName = "primo", Row = 1, Index = 2, NumberOfColumns = 4)]
        [FormFieldAttribute(Type = FormFieldTypes.Select)]
        [SelectTemplateOptions(Label = "Magazzino",
                               Placeholder = "Indicare il Cliente a cui fa capo il documento...",
                               Required = true,
                               Callback = "/api/Common/LoadCustomers", ForceLoad = true)]
        public Guid Customer { get; set; }

        [Events(Event = EventTypes.OnChange, Callback = "VerificaCodiceArticolo")]
        [FieldGroup(GroupName = "primo", Row = 1, Index = 3, NumberOfColumns = 4)]
        [FormFieldAttribute(Type = FormFieldTypes.UISelect2)]
        [UISelect2TemplateOptions(Label = "Fornitore",
                               Required = false,
                               MinimumInputLength = 2,
                               Callback = "/api/Fornitori/LoadFornitoriByCustomerOrAll", ForceLoad = true, DependsBy = "Customer")]   
        public Guid Fornitore { get; set; }

        /**/
        [FieldGroup(GroupName = "secondo", Row = 2, Index = 1, NumberOfColumns = 4)]
        [FormFieldAttribute(Type = FormFieldTypes.Select)]
        [SelectTemplateOptions(Label = "Tipo Doc.",
                               Placeholder = "Indicare il tipo di documento...",
                               Required = true,
                               Callback = "/api/Common/LoadTipoDocumento", ForceLoad = true)]
        public Guid TipoDocumento { get; set; }

        [FieldGroup(GroupName = "secondo", Row = 2, Index = 2, NumberOfColumns = 4)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Numero Doc.",
            Placeholder = "Max 50 car.",
            Required = true,
            MinLength = 0,
            MaxLength = 50)]
        public string NumeroDocumento { get; set; }

        [FieldGroup(GroupName = "secondo", Row = 2, Index = 3, NumberOfColumns = 4)]
        [FormFieldAttribute(Type = FormFieldTypes.GrayParrotDateTimePicker)]
        [GrayParrotDateTimePickerOptionsAttribute(Label = "Data Doc.",
                                 Placeholder = "Indicare la data del documento...",
                                 Required = true,
                                 MinuteStep = 10,
                                 Format = "dd/mm/yyyy",
                                 ShowTimePanel = false,
                                 WithInitialDate = true)]
        public DateTime DataDocumento { get; set; }

        /**/
        [Events(Event = EventTypes.OnChange, Callback = "CambiaFoto")]
        [FieldGroup(GroupName = "terzo", Row = 3, Index = 1, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Select)]
        [SelectTemplateOptions(Label = "Articolo",
                               Required = true,
                               Callback = "/api/AnagraficaArticoli/LoadCodiciArticoli", ForceLoad = true, DependsBy = "Customer")]
        public Guid Articolo { get; set; }

        [AddOn(Position = Position.Right, Text = "", Class = "glyphicon glyphicon-remove", OnClick = "CancellaCodiceFornitore")]
        [Events(Event = EventTypes.OnChange, Callback = "TrovaArticolo")]
        [FieldGroup(GroupName = "terzo", Row = 3, Index = 2, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Select)]
        [SelectTemplateOptions(Label = "Cod. Fornitore",
                               Required = false,
                               Callback = "/api/AnagraficaCodiciFornitori/LoadAllCodiciFornitoreByCliente", ForceLoad = true, DependsBy = "Customer, Fornitore")]
        public Guid CodiceFornitore { get; set; }

        [AddOn(Position = Position.Right, Text = "", Class = "quantitaAOR")]
        [FieldGroup(GroupName = "terzo", Row = 3, Index = 3, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Number)]
        [NumericTemplateOptions(Label = "Q.ta Grz.", Required = true, Placeholder = "", Disabled = false)]
        public decimal Quantita { get; set; }

        [AddOn(Position = Position.Right, Text = "", Class = "qtaFattAOR")]
        [FieldGroup(GroupName = "terzo", Row = 3, Index = 4, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Number)]
        [NumericTemplateOptions(Label = "Q.ta Fatt.", Required = false, Placeholder = "", Disabled = false, Value = 0)]
        public decimal QtaFatt { get; set; }

        /**/
        [FieldGroup(GroupName = "quarto", Row = 4, Index = 1, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Descrizione", Placeholder = "", Required = false, Disabled = true)]
        public string Descrizione { get; set; }

        [FieldGroup(GroupName = "quarto", Row = 4, Index = 2, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Tipologia", Placeholder = "", Required = false, Disabled = true)]
        public string Tipologia { get; set; }

        [FieldGroup(GroupName = "quarto", Row = 4, Index = 3, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Serie/Fam.", Placeholder = "", Required = false, Disabled = true)]
        public string SerieFamiglia { get; set; }

        [FieldGroup(GroupName = "quarto", Row = 4, Index = 4, NumberOfColumns = 3)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Dimensioni", Placeholder = "", Required = false, Disabled = true)]
        public string Dimensioni { get; set; }

        /**/
        [FieldGroup(GroupName = "quinto", Row = 5, Index = 1, NumberOfColumns = 9)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Note Articolo", Placeholder = "", Required = false, Disabled = true)]
        public string NoteArticolo { get; set; }

        /**/
        [FieldGroup(GroupName = "sesto", Row = 6, Index = 1, NumberOfColumns = 12)]
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptions(Label = "Note Dettaglio", Placeholder = "Indicare le note se necessarie...", Required = false)]
        public string Note { get; set; }

        /**/
        [FormFieldAttribute(Type = FormFieldTypes.Checkbox)]
        [CheckBoxTemplateOptions(Label = "XXXX", Placeholder = "", Required = false, DefaultValue = false, Hidden = true)]
        public bool IsXxxx { get; set; }
    }
}
